package com.dsl.dslallinone.common.config;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * 指标配置
 */
@Data
@Schema(description = "指标配置")
public class MetricConfig {
    @Schema(description = "函数名", required = true,
            example = "sum",
            allowableValues = {"sum", "avg", "max", "min", "count", "distinct_count", "yoy", "mom", "topN", "pct_of_total"})
    @NotBlank(message = "函数名不能为空")
    private String fn;

    @Schema(description = "表达式", required = true, example = "value")
    @NotBlank(message = "表达式不能为空")
    private String expr;

    @Schema(description = "别名", required = true, example = "sum_value")
    @NotBlank(message = "别名不能为空")
    private String as;

    @Schema(description = "单位", example = "kWh")
    private String unit;

    public MetricConfig() {}

    public MetricConfig(String fn, String expr, String as, String unit) {
        this.fn = fn;
        this.expr = expr;
        this.as = as;
        this.unit = unit;
    }
}
